var express = require('express')
var router = express.Router()
var bt = require('../../common/blog').dal_blog_type
var db = require('../../common/blog').dal_blog

router.get('/main', (req, res) => {
    bt.getData('', function(dataList) {
        db.getData('', function(blogList) {
            res.render('user/main', { types: dataList, blogs: blogList })
        })
    })
})

router.get('/main/:name', (req, res) => {
    var blogType = req.params.name
    bt.getData('', function(dataList) {
        db.getData(blogType, function(blogList) {
            res.render('user/main', { types: dataList, blogs: blogList })
        })
    })
})

module.exports = router